open Gmp

type frng = FltRng of float * float;;
type irng = IntRng of int * int;;

let floatRng (a, b) = FltRng(a,b);;
let intRng (a, b) = IntRng(a,b);;
let randInit = RNG.default;; 
let state = randInit;;
let getRandInt = function
        | IntRng(lo,hi) ->  
                let boundary = hi-lo
                in
                let zboundary = Z.of_int boundary
                in        
                let c = Z.urandomm state zboundary
                in
                let res = Z.to_int c
                in
                res+lo
let getRandFloat = function
        | FltRng(lo,hi) ->
                let precision = 7
                in
                let b = F.urandomb state precision
                in
                let res = F.to_float b
                in
                res*.(hi-.lo)+.lo 

